﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DelegateDemo
{
    public partial class FrmOne : Form
    {
        public string Info;

        public FrmOne()
        {
            InitializeComponent();
        }

        // 【1】创建委托，谁使用，谁创建
        public Action<string> SendMsg;

        private void uiButton1_Click(object sender, EventArgs e)
        {
            // 【4】 执行委托
            SendMsg?.Invoke(uiTextBox1.Text);

            #region 使用窗体返回值进行传递
            Info = uiTextBox1.Text;
            this.DialogResult = DialogResult.OK;
            #endregion

        }

        private void uiButton2_Click(object sender, EventArgs e)
        {
            FrmTwo frmTwo = new FrmTwo();

            frmTwo.ShowDialog();
        }
    }
}
